package com.msh.starter.redis.config;

import com.msh.frame.client.interfaces.IClassLoadLog;
import com.msh.frame.interfaces.ICacheManager;
import com.msh.starter.redis.cache.RedisCacheManager;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.RedisTemplate;


@ConditionalOnProperty(name = "msh.starter.redis.cacheManager.enable", havingValue = "true", matchIfMissing = true)
public class RedisCacheManagerConfig implements IClassLoadLog {

  @Bean
  public ICacheManager redisCacheManager(RedisTemplate redisTemplate){
    return new RedisCacheManager(redisTemplate);
  }

  @Override
  public String logInfo() {
    return new StringBuilder()
        .append("----执行类 ")
        .append(RedisCacheManagerConfig.class)
        .append("\r\n")
        .append("--------加载类 ")
        .append(RedisCacheManager.class)
        .append("(ICacheManager)\r\n")
        .toString();
  }
}
